{% extends 'index.html' %}
{% block page-content %}
<div id="page-wrapper">
    <div class="row">
         <div class="col-lg-12">
              <h1 class="page-header"> 任务修改中心</h1>
         </div>
                <!-- /.col-lg-12 -->
    </div>
	<div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                           	 任务修改
                        </div>
                        <div class="panel-body">
                            <div class="row">
                            	<div class="col-lg-3">
                            	</div>
                                <div class="col-lg-6">
                                <legend>计划任务配置 - 必填信息</legend>
                                    <form role="form" method="post" id="addCrontab" class="main form-horizontal" enctype="multipart/form-data" >{% csrf_token %}
										<fieldset>															
											<div class="form-group">
												 <label class="col-sm-2 control-label">分</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_minute" placeholder="*/1" value="{{ cron.cron_minute|default:"" }}"  class="input-xlarge" required pattern="^(\*|\*\/[0-5]?[0-9]|[0-5]?[0-9]|)$"  title="正确格式：00-59 or * or */1"  />
												 </div>
											</div>
											
											<div class="form-group">
												 <label class="col-sm-2 control-label">时</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_hour" placeholder="0-23" value="{{ cron.cron_hour|default:"" }}" class="input-xlarge" required pattern="^(\*|\*\/[0-2]?[0-9]|[0-2]?[0-9])$"  title="正确格式：0-23 or * or */1" />
												 </div>
											</div>	
					
											<div class="form-group">
												 <label class="col-sm-2 control-label">日</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_day" placeholder="1-31" value="{{ cron.cron_day|default:"" }}" class="input-xlarge" required pattern="^(\*|[0-3]?[0-9]|\*\/[0-3]?[0-9])$"  title="正确格式：01 or * or */1"/>
												 </div>
											</div>		
					
											<div class="form-group">
												 <label class="col-sm-2 control-label">月</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_month" placeholder="*" value="{{ cron.cron_week|default:"" }}"  class="input-xlarge"  required  pattern="^(\*|[0-1]?[0-9]|\*\/[0-1]?[0-9])$"  title="正确格式：01 or * or */1"/>
												 </div>
											</div>															
														
											<div class="form-group">
												 <label class="col-sm-2 control-label">周</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_week" placeholder="0-7" value="{{ cron.cron_month|default:"" }}" class="input-xlarge"  required pattern="^(\*|[0-6]||[0-6]\*\/)$"  title="正确格式：01 or * or */1"/>
												 </div>
											</div>	

											<div class="form-group">
												 <label class="col-sm-2 control-label">命令</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_command" placeholder="/usr/sbin/ntpdate time.windows.com" value="{{ cron.cron_command|default:"" }}" class="input-xlarge"  required/>
												 </div>
											</div>
											
											<div class="form-group">
												 <label class="col-sm-2 control-label">上传脚本</label>
												 <div class="col-sm-6">
												 	<input type="file" name="cron_script" placeholder="任务描述" value="" />
												 </div>
											</div>		

											<div class="form-group">
												 <label class="col-sm-2 control-label" >脚本路径</label>
												 <div class="col-sm-6">
												 	{% if cron.cron_script_path %}
												 		<input type="text" class="form-control"  name="cron_script_path" placeholder="/usr/local/src/update.sh" value="{{ cron.cron_script_path|default:"" }}" class="input-xlarge"  title="正确格式：/usr/local/src/update.sh"/>
												 	{% else %}
												 		<input type="text" class="form-control"  name="cron_script_path" placeholder="/usr/local/src/update.sh" value="" class="input-xlarge"  title="正确格式：/usr/local/src/update.sh"/>
												 	{% endif %}
												 	
												 </div>
											</div>											
																					
											<div class="form-group">
												 <label class="col-sm-2 control-label">用户</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_user" placeholder="root" value="{{ cron.cron_user|default:"" }}"   class="input-xlarge" />
												 </div>
											</div>															
												
<!-- 											<div class="form-group"> -->
<!-- 												 <label class="col-sm-2 control-label">服务器</label> -->
<!-- 												 <div class="col-sm-6"> -->
<!-- 												   <select class="form-control" name="cron_server"  > -->
<!-- 												   		<option  value="">请选择一台主机</option> -->
<!-- 															{% for ds in serverList %} -->
<!-- 																{% if ds.id == cron.cron_server_id %} -->
<!-- 																	<option selected="selected" value="{{ cron.cron_server_id }}" name="cron_server">{{ds.ip}}</option> -->
<!-- 																{% else %} -->
<!-- 																	<option  value="{{ ds.id }}" name="cron_server">{{ds.ip}}</option> -->
<!-- 																{% endif %} -->
<!-- 															{% endfor %}							   		 -->
<!-- 													</select>							 	 -->
<!-- 												 </div> -->
<!-- 											</div>													 -->
												
											<div class="form-group">
												 <label class="col-sm-2 control-label">任务名称</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_name" placeholder="计划任务名称" value="{{ cron.cron_name|default:"" }}"  class="input-xlarge"  disabled/>
												 </div>
											</div>
											
											<div class="form-group">
												 <label class="col-sm-2 control-label">任务描述</label>
												 <div class="col-sm-6">
												 	<input type="text" class="form-control" name="cron_desc" placeholder="任务描述" value="{{ cron.cron_desc|default:"" }}" class="input-xlarge"  />
												 </div>
											</div>						
											

											<div class="form-group">
												 <label class="col-sm-2 control-label">激活任务</label>
												 <div class="col-sm-6">
												   <select class="form-control" name="cron_status"  >
												   		{% if cron.cron_status == 0 %}
												   			<option selected="selected" value="0">不激活</option>
												   			<option  value="1">已激活</option>
												   		{% else %}
												   			<option  value="0">不激活</option>
												   			<option selected="selected" value="1">已激活</option>
												   		{% endif %}
												   										   		
													</select>							 	
												 </div>
											</div>														
																																											
											
											</fieldset>
											<legend></legend>
											<div class="form-group">
											<label class="col-sm-3 control-label"></label>
											<button type="button"  class="btn btn-default" >撤销操作</button>
									 		<button type="submit"  class="btn btn-default" >确认提交</button>
									 		</div>
									 		
										</form>	
                                </div>
                                <!-- /.col-lg-6 (nested) -->
                                <!-- /.col-lg-6 (nested) -->
                            </div>
                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>    
</div>

<script type="text/javascript">

	   
	   function selectAll(){
		   var checklist = document.getElementsByName("server");
		     if(document.getElementById("controlAll").checked)
		     {
		     for(var i=0;i<checklist.length;i++)
		     {
		        checklist[i].checked = 1;
		     } 
		   }else{
		    for(var j=0;j<checklist.length;j++)
		    {
		       checklist[j].checked = 0;
		    }
		   }
		  }
	  {% if errorInfo %}
	  	window.wxc.xcConfirm("{{errorInfo}}", window.wxc.xcConfirm.typeEnum.error);
	  {% endif %}
</script>

{% endblock %}